import Vue from "vue";

import "normalize.css/normalize.css"; // a modern alternative to CSS resets
import Element from "element-ui";
import "./styles/element-variables.scss";

import "@/styles/index.scss"; // global css

import App from "./App";
import store from "./store";
import router from "./router";

import i18n from "./lang"; // internationalization
import "./icons"; // icon
import "./utils/error-log"; // error log
import request from "@/utils/request";
import Util from "./utils/utils.js";

import * as filters from "./filters"; // global filters
import { hasPermission, hasNoPermission, hasAnyPermission } from "./utils/permissionDirect";

import AFTableColumn from "af-table-column";
import moment from "moment"; // moment(new Date()).format('YYYY-MM-DD')

import "./assets/iconfont/iconfont.css";
import "font-awesome/css/font-awesome.min.css";

import "@/assets/font/font.css"; // 管道字体

import BaiduMap from "vue-baidu-map";

// 高德地图
import VueAMap from "@vuemap/vue-amap";
import "@vuemap/vue-amap/dist/style.css";

import CodeEditor from 'bin-code-editor';
import 'bin-code-editor/lib/styles/index.css'

Vue.use(Element, {
  i18n: (key, value) => i18n.t(key, value)
});

const Plugins = [hasPermission, hasNoPermission, hasAnyPermission];
Plugins.map(plugin => {
  Vue.use(plugin);
});

Vue.use(AFTableColumn);

Vue.use(BaiduMap, {
  // ak 是在百度地图开发者平台申请的密钥 详见 http://lbsyun.baidu.com/apiconsole/key */
  ak: "nSxiPohfziUaCuONe4ViUP2N",
  isOnlineMap: true
});

VueAMap.initAMapApiLoader({
  key: "f580abd04bfefc0a654d607896df985d",
  // 插件集合 （插件按需引入）
  plugin: ["AMap.Geolocation", "AMap.MapType"]
});
Vue.use(VueAMap);

Vue.use(CodeEditor);

Vue.prototype.$util = Util;
Vue.prototype.$post = request.post;
Vue.prototype.$postBody = request.postBody;
Vue.prototype.$get = request.get;
Vue.prototype.$put = request.put;
Vue.prototype.$delete = request.delete;
Vue.prototype.$download = request.download;
Vue.prototype.$upload = request.upload;
Vue.prototype.$login = request.login;
Vue.prototype.$moment = moment;

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
});

Vue.config.productionTip = false;

new Vue({
  el: "#app",
  router,
  store,
  i18n,
  render: h => h(App)
});
